<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>类组件</title>
</head>
<body>
  <!-- 容器 -->
  <div id="test"></div>

  <script crossorigin src="https://unpkg.com/react@16/umd/react.development.js"></script>
  <script crossorigin src="https://unpkg.com/react-dom@16/umd/react-dom.development.js"></script>
  <script src="https://unpkg.com/babel-standalone@6/babel.min.js"></script>

  <script type="text/babel">
    // React.Component的Component是React内置的类
    class MyComponent extends React.Component{
      render() {
        console.log(this)   // this指向的是MyComponent的实例对象
        // render是放在哪里的 —— 类(即：MyComponent)的原型对象上，供实例使用
        return <h2>我是用函数定义的组件（适用于【简单组件】的定义）</h2>
      }
    }
    ReactDOM.render(<MyComponent/>, document.getElementById('test'))
  </script>
</body>
</html>